home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / tools / czesc_1 / cpdist / filecopy.h < prev    next >
C/C++ Source or Header  |  1994-01-12  |  2KB  |  64 lines

  1. /*
  2.  *  FILECOPY.H
  3.  *
  4.  *  (c)Copyright 1990,93 by Tobias Ferber,  All Rights Reserved.
  5.  */
  6.  
  7. #ifndef FILECOPY_H
  8. #define FILECOPY_H
  9.  
  10. #include <stdio.h>
  11.  
  12. /* increase readability */
  13. typedef unsigned char uchar;
  14. typedef unsigned long ulong;
  15.  
  16. /*
  17.    By default, filecopy() will try to malloc() a copy buffer of
  18.    MAXIMUM_BUFFERSIZE bytes.  Note that last is limited to 64K
  19.    because malloc() can't allocate more at a time by ANSI definition.
  20.    There are however situations where you don't want filecopy() to
  21.    allocate this buffer on it's own each time.  In this case you can
  22.    set a permanent copy buffer via fc_setbuf().  If you do so, please
  23.    don't forget to free() this buffer again via fc_setbuf(0L) after
  24.    having copied all your files.
  25.    Note that fc_setbuf will not check wether you try to allocate
  26.    more than MAXIMUM_BUFFERSIZE bytes, which makes sense if your
  27.    compiler has no limit for malloc() or fc_setbuf() has been patched
  28.    to use something else than malloc() to get some memory.
  29.    Note also that if filecopy fails to allocate a buffer, it will
  30.    copy your file byte for byte.
  31. */
  32.  
  33. #define MAXIMUM_BUFFERSIZE (1L<<16)
  34.  
  35. /*
  36.  * The ftell() function in the c.lib of Dillon's shareware C Compiler DICE
  37.  * seems to be somewhat buggy.  If you've got similar problems with ftell()
  38.  * you can comment out the following
  39.  
  40. #define BUGGY_FTELL
  41.  
  42.  * or simply compile using the -DBUGGY_FTELL option with the result that
  43.  * filecopy() will count bytes instead of asking ftell() about the file size.
  44.  */
  45.  
  46. /* Do my prototypes look like those of Cray Research, Inc. ?! */
  47.  
  48. #ifndef __
  49.  
  50. #if defined (__STDC__) || defined(__cplusplus)
  51. #define __(protos) protos
  52. #else /* !(__STDC__ || __cplusplus) */
  53. #define __(protos) ()
  54. #endif /* __STDC__ || __cplusplus */
  55.  
  56. #endif /* !__ */
  57.  
  58. extern ulong fc_setbuf __( (ulong numbytes) );
  59. extern long filecopy   __( (FILE *src, FILE *dst, long n) );
  60.  
  61. /* see filecopy.c for further details... */
  62.  
  63. #endif /* !FILECOPY_H */
  64.